#include <iostream>
using namespace std;

int main() {
    int a, b;
    int count=0;
    while (cin >> a >> b)
    {
        for (int i = a; i <= b; i++)
        {
            int tmp = i;
            // 2 12 20 21 22 23 24
            while (tmp)
            {
                if (tmp % 10 == 2)
                {
                    count++;
                }
                if (tmp / 10 == 2)
                {
                    count++;
                }
                tmp /= 10;
                if (tmp == 2)
                {
                    count--;
                }
            }
        }
    }
    cout << count << endl;
}
